<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>渲染函数</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
    <div id="app">
       
    </div>
    <div>
        <anchored-heading :level="2">Hello-world!</anchored-heading>
    </div>


    <script>

        Vue.component('anchored-heading', {
            render: function (createElement) {
                console.log(this.level);
                console.log(this.$slots);
                return createElement(
                    'h' + this.level,   // 标签名称
                    this.$slots.default // 子节点数组
                )
            },
            props: {
                level: {
                    type: Number,
                    required: true
                }
            }
        })
        var app = new Vue({
            el: "#app",

            // 通过渲染函数
            render:function(createElement){
                let vnode = createElement(
                    "h1",//第一个参数
                    {   //第二个参数
                        class:{
                            foo:true,
                        },
                        style:{
                            color:"red",
                        },
                        attrs:{
                            title:"标题属性"
                        }
                    },
                    "你好")//第三个参数
                console.log(vnode);
                return vnode
            }
        })

    </script>
</body>

</html>